<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class UpdateUserRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'userName' => 'required|regex:/^\w{6,20}$/',
            'password' => 'required|regex:/^\S{6,20}$/|same:passwd'
        ];
    }
    //显示错误信息
     public function messages()
    {
        return [
            'userName.required'=>'用户名必填',
            'userName.unique'=>'用户名已存在',
            'userName.regex'=>'用户名格式不正确',
            'password.regex'=>'密码格式不正确',
            'password.same'=>'两次密码不一样',
            'password.required'=>'密码必填'
        ];
    }
}
